#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2020/5/6  16:49
# @Author: 余浪人
# @email: yulangren520@gmail.com
from apscheduler.schedulers.blocking import BlockingScheduler
from conf import *
from spiders.spider import IpAgency
from verify import verify_pool_inland, verify_pool_foreign


def dispatch_spider_main():
    ip = IpAgency()  # 实例化一个调度器
    scheduler = BlockingScheduler()
    scheduler.add_job(ip.xiCiDaiLi, 'interval', seconds=START_TIME, replace_existing=True)
    scheduler.add_job(ip.KuaiDaiLi, 'interval', seconds=START_TIME, replace_existing=True)
    scheduler.add_job(ip.ip89, 'interval', seconds=START_TIME, replace_existing=True)
    scheduler.add_job(ip.yunDaiLi_inland, 'interval', seconds=START_TIME, replace_existing=True)
    scheduler.add_job(ip.yunDaiLi_foreign, 'interval', seconds=START_TIME, replace_existing=True)
    scheduler.add_job(ip.IP_Hai, 'interval', seconds=START_TIME, replace_existing=True)
    scheduler.add_job(ip.IP_Hai_foreign, 'interval', seconds=START_TIME, replace_existing=True)
    scheduler.add_job(ip.jianGxianLi, 'interval', seconds=START_TIME, replace_existing=True)
    scheduler.start()  # 开始运行调度器


def dispatch_verify_main():
    s = BlockingScheduler()
    s.add_job(verify_pool_inland, 'interval', seconds=VERIFY_INLAND_TIME, replace_existing=True)
    s.add_job(verify_pool_foreign, 'interval', seconds=VERIFY_FOREIGN_TIME, replace_existing=True)
    s.start()  # 开始运行调度器


if __name__ == '__main__':
    dispatch_spider_main()
